type intpair = record
  a,b : int64;
end;

type pqueue = ^tqueue;
     tqueue = record
       a : longint;
       next : pqueue;
     end;

var
  a : array [1..5000,1..5000] of boolean;
  e : array [1..5000] of intpair;
  pow : array [1..5000] of integer;
  l : array [1..5000] of pqueue;
  n,k : int64;
  val3_3, val3_2, val4_6, val4_5, val4_4_quadro, val4_4_huita : int64;
  val4_3_bambuk, val4_3_star, val4_2_parallel : int64;

procedure push_front(var p : pqueue; n : integer);
var t : pqueue;
begin
  new(t);
  t^.next := p;
  t^.a := n;
  p := t;
end;

function calc3_3 : int64;
var ans : int64; i,j : longint;
begin
  if val3_3 <> -1 then begin calc3_3 := val3_3; exit(); end;
  ans := 0;
  for i := 1 to n do
    for j := 1 to k do
      if a[e[i].a,j] and a[e[i].b,j] then inc(ans);
  calc3_3 := ans div 3;
  val3_3 := ans div 3;
end;

function calc3_2 : int64;
var ans : int64; i,j : longint;
begin
  ans := 0;
  if val3_2 <> -1 then begin calc3_2 := val3_2; exit(); end;
  for i := 1 to n do
    for j := i+1 to n do
      if (e[i].a=e[j].a)or(e[i].a=e[j].b)or(e[i].b=e[j].a)or(e[i].b=e[j].b) then 
        inc(ans);
  calc3_2 := ans - 3*calc3_3(); 
  val3_2 := ans - 3*calc3_3();
end;

function calc3_1 : int64;
begin
  calc3_1 := n*(k-2) - 2*calc3_2() - 3*calc3_3();
end;

function calc4_6 : int64;
var ans : int64; i,j : longint;
begin
  if val4_6 <> -1 then begin calc4_6 := val4_6; exit(); end;
  ans := 0;
  for i := 1 to n do
    for j := i+1 to n do
      begin     
        if (e[i].a=e[j].a)or(e[i].a=e[j].b)or(e[i].b=e[j].a)or(e[i].b=e[j].b) then
          continue;
        if a[e[i].a,e[j].a] and a[e[i].a,e[j].b] and 
           a[e[i].b,e[j].a] and a[e[i].b,e[j].b] then
             inc(ans);
      end;
  calc4_6 := ans div 3;
  val4_6 := ans div 3;
end;

function calc4_5 : int64;
var ans : int64; i,j : longint;
begin
  if val4_5 <> -1 then begin calc4_5 := val4_5; exit(); end;
  ans := 0;
  for i := 1 to n do
    for j := i+1 to n do
      begin
        if (e[i].a=e[j].a)or(e[i].a=e[j].b)or(e[i].b=e[j].a)or(e[i].b=e[j].b) then
          continue; 
        if not a[e[i].a,e[j].a] and a[e[i].a,e[j].b] and 
           a[e[i].b,e[j].a] and a[e[i].b,e[j].b] then
             inc(ans);
        if a[e[i].a,e[j].a] and not a[e[i].a,e[j].b] and 
           a[e[i].b,e[j].a] and a[e[i].b,e[j].b] then
             inc(ans);
        if a[e[i].a,e[j].a] and a[e[i].a,e[j].b] and 
           not a[e[i].b,e[j].a] and a[e[i].b,e[j].b] then
             inc(ans);
        if a[e[i].a,e[j].a] and a[e[i].a,e[j].b] and 
           a[e[i].b,e[j].a] and not a[e[i].b,e[j].b] then
             inc(ans);
      end;
  calc4_5 := ans div 2;
  val4_5 := ans div 2;
end;

function calc4_4_quadro : int64;
var ans : int64; i,j : longint;
begin
  if val4_4_quadro <> -1 then begin calc4_4_quadro := val4_4_quadro; exit(); end;
  ans := 0;
  for i := 1 to n do
    for j := i+1 to n do
      begin
        if (e[i].a=e[j].a)or(e[i].a=e[j].b)or(e[i].b=e[j].a)or(e[i].b=e[j].b) then
          continue; 
        if a[e[i].a,e[j].a] and not a[e[i].a,e[j].b] and 
           not a[e[i].b,e[j].a] and a[e[i].b,e[j].b] then
             inc(ans);
        if not a[e[i].a,e[j].a] and a[e[i].a,e[j].b] and 
           a[e[i].b,e[j].a] and not a[e[i].b,e[j].b] then
             inc(ans);
      end;
  calc4_4_quadro := ans div 2;
  val4_4_quadro := ans div 2;
end;

function calc4_4_huita : int64;
var ans : int64; i,j : longint;
begin
  if val4_4_huita <> -1 then begin calc4_4_huita := val4_4_huita; exit(); end;
  ans := 0;
  for i := 1 to n do
    for j := i+1 to n do
      begin
        if (e[i].a=e[j].a)or(e[i].a=e[j].b)or(e[i].b=e[j].a)or(e[i].b=e[j].b) then
          continue; 
        if a[e[i].a,e[j].a] and not a[e[i].a,e[j].b] and 
           a[e[i].b,e[j].a] and not a[e[i].b,e[j].b] then
             inc(ans);
        if not a[e[i].a,e[j].a] and a[e[i].a,e[j].b] and 
           not a[e[i].b,e[j].a] and a[e[i].b,e[j].b] then
             inc(ans);
        if a[e[i].a,e[j].a] and a[e[i].a,e[j].b] and 
           not a[e[i].b,e[j].a] and not a[e[i].b,e[j].b] then
             inc(ans);
        if not a[e[i].a,e[j].a] and not a[e[i].a,e[j].b] and 
           a[e[i].b,e[j].a] and a[e[i].b,e[j].b] then
             inc(ans);
      end;
  calc4_4_huita := ans;
  val4_4_huita := ans;
end;

function calc4_4 : int64;
begin
  calc4_4 := calc4_4_quadro() + calc4_4_huita();
end;

function calc4_3_bambuk : int64;
var ans : int64; i,j : longint;
begin
  if val4_3_bambuk <> -1 then begin calc4_3_bambuk := val4_3_bambuk; exit(); end;
  ans := 0;
  for i := 1 to n do
    for j := i+1 to n do
      begin
        if (e[i].a=e[j].a)or(e[i].a=e[j].b)or(e[i].b=e[j].a)or(e[i].b=e[j].b) then
          continue; 
        if a[e[i].a,e[j].a] and not a[e[i].a,e[j].b] and 
           not a[e[i].b,e[j].a] and not a[e[i].b,e[j].b] then
             inc(ans);
        if not a[e[i].a,e[j].a] and a[e[i].a,e[j].b] and 
           not a[e[i].b,e[j].a] and not a[e[i].b,e[j].b] then
             inc(ans);
        if not a[e[i].a,e[j].a] and not a[e[i].a,e[j].b] and 
           a[e[i].b,e[j].a] and not a[e[i].b,e[j].b] then
             inc(ans);
        if not a[e[i].a,e[j].a] and not a[e[i].a,e[j].b] and 
           not a[e[i].b,e[j].a] and a[e[i].b,e[j].b] then
             inc(ans);
      end;
  calc4_3_bambuk := ans;
  val4_3_bambuk := ans;
end;

var maybe : array [0..5000] of longint;

function calc4_3_star : int64;
var ans, cans, lans, ans2, ans3 : int64;
    i,j : longint;
    pi1 : pqueue;
    i1,i2,i3 : longint;
    v1,v2,v3 : longint;
begin
  if val4_3_star <> -1 then begin calc4_3_star := val4_3_star; exit(); end;
  ans := 0;
  for i := 1 to k do
    begin
      if pow[i] < 3 then continue;
      maybe[0] := 0;;
      lans := 0;
      pi1 := l[i];
      while pi1 <> nil do
        begin
          if pow[pi1^.a] = 1 then 
            inc(lans)
          else
            begin
              inc(maybe[0]); maybe[maybe[0]] := pi1^.a;
            end;
          pi1 := pi1^.next;
        end;
      ans2 := 0; ans3 := 0;
      for i1 := 1 to maybe[0] do
        begin
          v1 := maybe[i1];
          for i2 := i1+1 to maybe[0] do
            begin
              v2 := maybe[i2];
              if a[v1,v2] then continue;
              inc(ans2);
              for i3 := i2+1 to maybe[0] do
                begin
                  v3 := maybe[i3];
                  if not a[v1,v3] and not a[v2,v3] then inc(ans3);
                end;
            end;
        end;
      ans := ans + lans*(lans-1)*(lans-2) div 6 + 
             lans*(lans-1)*maybe[0] div 2 + lans*ans2 + ans3;
    end;
  calc4_3_star := ans;
  val4_3_star := ans;
end;

function calc4_3_govno : int64;
begin
  calc4_3_govno := calc3_3()*(k-3) - calc4_4_huita() - 2*calc4_5 - 4*calc4_6;
end;

function calc4_3 : int64;
begin
  calc4_3 := calc4_3_bambuk() + calc4_3_star() + calc4_3_govno();
end;

function calc4_2_parallel : int64;
var ans : int64; i,j : longint;
begin
  if val4_2_parallel <> -1 then begin calc4_2_parallel := val4_2_parallel; exit(); end;
  ans := 0;
  for i := 1 to n do
    for j := i+1 to n do
      begin
        if (e[i].a=e[j].a)or(e[i].a=e[j].b)or(e[i].b=e[j].a)or(e[i].b=e[j].b) then
          continue; 
        if not a[e[i].a,e[j].a] and not a[e[i].a,e[j].b] and 
           not a[e[i].b,e[j].a] and not a[e[i].b,e[j].b] then
             inc(ans);
      end;
  calc4_2_parallel := ans;
  val4_2_parallel := ans;
end;

function calc4_2_share : int64;
begin
  calc4_2_share := calc3_2()*(k-3) - 2*calc4_3_bambuk() - 3*calc4_3_star() -
                   4*calc4_4_quadro() - 2*calc4_4_huita() - 2*calc4_5();
end;

function calc4_2 : int64;
begin
  calc4_2 := calc4_2_parallel() + calc4_2_share();
end;

function calc4_1 : int64;
begin
  calc4_1 := n*(k-2)*(k-3) div 2 - 2*calc4_2() - 3*calc4_3() - 4*calc4_4() -
             5*calc4_5() - 6*calc4_6();
end;

function calc1 : int64;
begin
  calc1 := k;
end;

function calc2 : int64;
begin
  if k<2 then calc2 := 0 else calc2 := k*(k-1) div 2 - n;
end;

function calc3 : int64;
begin
  if k<3 then calc3 := 0 else 
    calc3 := k*(k-1)*(k-2) div 6 - calc3_1() - calc3_2() - calc3_3();
end;

function calc4 : int64;
begin
  if k<4 then calc4 := 0 else
    calc4 := k*(k-1)*(k-2)*(k-3) div 24 - 
             calc4_1() - calc4_2() - calc4_3() - calc4_4() - calc4_5() - calc4_6();
end;

var t1,t2,i : longint;

begin
  val3_3 := -1;
  val3_2 := -1;
  val4_6 := -1;
  val4_5 := -1;
  val4_4_quadro := -1;
  val4_4_huita := -1;
  val4_3_bambuk := -1;
  val4_3_star := -1;
  val4_2_parallel := -1;
  read(k,n);
  fillchar(l, sizeof(l), 0);
  fillchar(pow, sizeof(pow), 0);
  if n = 0 then
    begin
      write(k + k*(k-1) div 2 + k*(k-1)*(k-2) div 6 + k*(k-1)*(k-2)*(k-3) div 24);
      halt();
    end;
  if 2*n = k*(k-1) then
    begin
      write(k);
      halt();
    end;
  for i := 1 to n do
    begin
      read(t1,t2);
      a[t1,t2] := true;
      a[t2,t1] := true;
      e[i].a := t1;
      e[i].b := t2;
      push_front(l[t1],t2);
      push_front(l[t2],t1);
      inc(pow[t1]);
      inc(pow[t2]);
    end;
  write(calc1()+calc2()+calc3()+calc4());
end.

